#pragma once

#include <iostream>
#include <string>
#include "localinetaddr.hpp"

class TcpServer;

// connection 链接
namespace Local_Connection
{
    class LocalConnection
    {
    public:
        /**********构造析构************** */
        LocalConnection() {}
        ~LocalConnection() {}

        /**********virtual************** */
        virtual void Recver() = 0;
        virtual void Sender() = 0;
        virtual void Excepter() = 0;

        /**********GetSet************** */
        void SetEvent(const uint32_t &events)
        {
            _events = events;
        }
        uint32_t GetEvent()
        {
            return _events;
        }
        void SetFd(int sockfd)
        {
            _sockfd = sockfd;
        }
        int GetFd()
        {
            return _sockfd;
        }

    private:
        int _sockfd;
        std::string _inbuffer; // 缓冲区 vector<char>
        std::string _outbuffer;

        // 回调指针
        TcpServer *_owner;

        // client info
        Local_Inetaddr::Inetaddr _client_addr;

        // 关心事件
        uint32_t _events;
    };
}